const express = require('express')
var router = express.Router()
const multer = require('multer')
const request = require('request')

var storage = multer.diskStorage({
	destination: './pages/',
	filename: function (req, file, cb) {
		console.log(file, '123')
		cb(null, file.originalname)
	},
})
var upload = multer({ 
	storage: storage
})

router.post('/pages', upload.single('page'), function (req, res, next) {
	upload.single('page')(req, res , function (err) {
		if (err) res.send({code: -1, msg: '失败'})
		let name = req.file
		console.log(name)
		res.send('success')
		// request.post({url: '', form: {}}, (error, response, body)=>{
		// 	console.log(error, response, body)
		// })
		
	})
})












module.exports = router;